﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Hosting;
using LynxWiki.Repository;
using LynxWiki.Search;

namespace IronWiki
{
    [Description("A class that provides access to wiki topic data")]
    public class WikiTopic
    {
        private string wikiPath;
        private string topicName;
        private WikiTopicRepository wtr;

        public string WikiLink { get; set; }

        [Description("A class initializer that provides access to wiki topic data")]
        public WikiTopic(string wikiPath, string topic)
        {
            this.wikiPath = wikiPath;
            this.topicName = topic;
            wtr = new WikiTopicRepository(Path.Combine(ConfigurationManager.AppSettings["HostWikiPath"], wikiPath.Replace("/", "\\")));
        }

        [Description("Retrieves a topic wikitext from the wiki repository")]
        public string GetTopicBody()
        {
            return "!!\"\"" + topicName + "\"\"\r\n\r\n" + wtr.GetCurrentVersion(topicName).WikiText.Replace("\n", "\r\n");
        }


    }

    [Description("A class that provides a List of WikiTopic classes")]
    public class WikiTopics
    {
        List<WikiTopic> WikiTopicList { get; set; }

        public WikiTopics()
        {
            WikiTopicList = new List<WikiTopic>();
        }


    }
}
